#-------------------------------------------------------------------------------
# Name:        模块1
# Purpose:
#
# Author:      sy
#
# Created:
# Copyright:   (c) sy
# Licence:     <your licence>
#-------------------------------------------------------------------------------
#  这是 mtk 项目的camera
import uiautomator2 as u2
import time
##import sys


with open("and_sn.txt", "r") as f:
    and_sn = f.readline()
    print(and_sn)

d = u2.connect("{}".format(and_sn))
if __name__ == '__main__':
    d = u2.connect()


f.close()
class camera_1():
##    def devices_connect(*args):
##        d = u2.connect("{}".format(args))

    #启动camera
    def start_app_1():

        d.app_stop("com.android.settings")
        time.sleep(3)
        d.app_start("com.android.settings")
        print("进入setting")
        time.sleep(3)
    def network_internet():
        time.sleep(2)
        print("点击network_internet")
        d(resourceId="android:id/title", text="Network & internet").click()
        time.sleep(3)
    def wifi_id():
        time.sleep(2)
        print("点击WI-FI")
        d(resourceId="android:id/title", text="Wi‑Fi").click()

        time.sleep(3)
    def wifi_ON():
        time.sleep(2)
        print("点击wifi 开，关闭wifi")
        d(resourceId="com.android.settings:id/switch_widget", text="ON").click()
        time.sleep(5)
    def wifi_OFF():
        time.sleep(2)
        print("点击wifi 关，打开wifi")
        d(resourceId="com.android.settings:id/switch_widget", text="OFF").click()
        time.sleep(18)
    def click_ssid(ssid):
        time.sleep(2)
        print("点击wifi AP {}".format(ssid))
        d(resourceId="android:id/title", text="{}".format(ssid)).click()
        time.sleep(2)
    def input_password(password):
        time.sleep(2)
        #d.set_fastinput_ime(True) # 切换成FastInputIME输入法
        time.sleep(2)
        print("输入密码 {}".format(password))
        d.shell('input text {}'.format(password))
        d(resourceId="android:id/button1", text="CONNECT").click()
        time.sleep(2)
    def forget_ssid(ssid):
        time.sleep(2)
        print("清除wifi连接状态")
        d(resourceId="android:id/title", text="{}".format(ssid)).click()
        time.sleep(4)
        d(resourceId="com.android.settings:id/button1", text="FORGET").click()
###Network & internet
##d(resourceId="android:id/title", text="Network & internet").click()
###Wi‑Fi
##d(resourceId="android:id/title", text="Wi‑Fi").click()
##
##d(resourceId="com.android.settings:id/switch_widget", text="ON").click()
##d(resourceId="com.android.settings:id/switch_widget", text="OFF").click()
##d.press("back")
##d.press("home")
def main():
    pass

if __name__ == '__main__':
    main()
